import sys
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QFormLayout
from PyQt5.QtWidgets import QPushButton, QLineEdit, QTextEdit


def user_submit():
    print("用户名：", edit_user.text())
    print("密码", edit_password.text())
    print("电话号码", edit_phone.text())


if __name__ == "__main__":
    # 1. 创建应用程序
    app = QApplication(sys.argv)

    # 2. 创建窗口
    w = QWidget()
    # 创建标题
    w.setWindowTitle("KZZ-260上位机")
    # w.resize(400, 300)

    # 创建垂直布局：vertical；创建水平布局：horizon
    layout = QFormLayout(w)
    edit_user = QLineEdit()
    edit_password = QLineEdit()
    edit_password.setEchoMode(QLineEdit.Password)
    edit_phone = QLineEdit()
    # 提交按钮
    button_submit = QPushButton("提交")
    button_submit.clicked.connect(user_submit)

    layout.addRow("用户名:", edit_user)
    layout.addRow("密码:", edit_password)
    layout.addRow("电话号码:", edit_phone)
    layout.addRow(button_submit)

    # layout.addWidget(edit_user)
    # layout.addWidget(edit_password)
    # layout.addWidget(edit_phone)
    # layout.addWidget(button_submit)

    # w.setLayout(layout)

    # 3. 显示窗口
    w.show()

    # 4. 等待APP停止
    sys.exit(app.exec_())
